﻿using System.Windows.Media;
using ImageProcessor.Shared;

namespace ImageProcessor.Tim
{
    public class TwoImagesExampleVM : ImageProcessorBaseVM
    {
        public TwoImagesExampleVM(MainViewModel mainVM) : base(mainVM)
        {
            
        }

        private ImageSource _resultImageOne;
        private ImageSource _resultImageTwo;

        /// <summary>
        /// Все просто, главное понять...
        /// Картинка 1, которая в контроле биндится так: EditValue="{Binding ResultImageOne, Mode=OneWay}"
        /// </summary>
        public ImageSource ResultImageOne
        {
            get { return _resultImageOne; }
            set
            {
                if(_resultImageOne == value)
                    return;
                _resultImageOne = value;
                OnPropertyChanged("ResultImageOne");
            }
        }

        /// <summary>
        /// Картинка 2, которая в контроле биндится так: EditValue="{Binding ResultImageTwo, Mode=OneWay}"
        /// </summary>
        public ImageSource ResultImageTwo
        {
            get { return _resultImageTwo; }
            set
            {
                if (_resultImageTwo == value)
                    return;
                _resultImageTwo = value;
                OnPropertyChanged("ResultImageTwo");
            }
        }

        protected override void Execute(object obj)
        {
            ResultImageOne = MainVM.SourceImage;

            ResultImageTwo = ResultImageOne;
        }

        protected override bool CanExecute(object obj)
        {
            return MainVM.SourceImage != null;
        }
    }
}